package com.cf.exception;

import lombok.Getter;

@Getter
public class MyException extends RuntimeException{
    private String code;

    private Object[] args;

    public MyException(){
        super();
    }

    public MyException(String message){
        super(message);
    }

    public MyException(Throwable cause){
        super(cause);
    }

    public MyException(String message, String code){
        super(message);
        this.code = code;
        System.out.println("message = " + message);
    }
    public MyException(Throwable cause, String message, String code){
        super(message, cause);
        this.code = code;
    }

    public MyException(String message, Throwable cause){
        super(message, cause);
    }
    public MyException(Throwable cause, String code, String message, Object... args){
        super(message, cause);
        this.code = code;
        this.args = args;
    }
    public MyException(String code, String message, Object... args){
        super(message);
        this.code = code;
        this.args = args;
    }

    @Override
    public String getMessage() {
        if (code != null) {
            if (args != null && args.length > 0) {
                return String.format(super.getMessage(), args);
            }
        }
        return super.getMessage();
    }
}
